package com.gitee.linzl.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

@RestController
public class ResourceController {
	@GetMapping("/current")
	public Principal user(Principal principal) {
		return principal;
	}

	@GetMapping("/auth")
	public Authentication getCurrentUserRedis(Authentication authentication) {
		return authentication;
	}

	@GetMapping("/query")
	@PreAuthorize("hasAnyAuthority('query')")
	public String query() {
		return "具有query权限";
	}
}
